package com.sheledon.flyCat.core.factory;

import com.sheledon.flyCat.annotation.springmvc.PathVariable;
import com.sheledon.flyCat.annotation.springmvc.RequestBody;
import com.sheledon.flyCat.annotation.springmvc.RequestParam;
import com.sheledon.flyCat.core.resolver.ParameterResolver;
import com.sheledon.flyCat.core.resolver.PathVariableParameterResovler;
import com.sheledon.flyCat.core.resolver.RequestBodyParameterResovler;
import com.sheledon.flyCat.core.resolver.RequestParamParameterResovler;

import java.lang.reflect.Parameter;

/**
 * @author sheledon
 */
public class ParameterResolverFactory {
    public static ParameterResolver get(Parameter parameter){
        if (parameter.isAnnotationPresent(RequestParam.class)){
            return new RequestParamParameterResovler();
        }
        if (parameter.isAnnotationPresent(RequestBody.class)){
            return new RequestBodyParameterResovler();
        }
        if (parameter.isAnnotationPresent(PathVariable.class)){
            return new PathVariableParameterResovler();
        }
        return null;
    }
}
